home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d20
/
yuck_200.arc
/
YUCK.H
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-29
|
15KB
|
252 lines
/* ------------------------------------------------------------------------- */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* Militantly Public Domain */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* ------------------------------------------------------------------------- */
/* If you find a way to replace a girlfriend on vacation with Yuck!, I'd */
/* like to hear about it <sigh, sniff, boohoo>. */
/* ========================================================================= */
/* MS-DOS (MS-C 5.10): "cl -nologo -Ox -AC -Gt2048 -W3 yuck.c yucknl.c" */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* Amiga (Lattice C 5.04): "lc -L -O yuck" */
/* ========================================================================= */
/* Yuck! 1.50 is cleaned up a lot (towards portability), and the TrapDoor */
/* people (Max Hantsch and Martin Laubach, 2:310/6) have implemented the */
/* necessary changes to get Yuck! to run on Amiga type machines. #define the */
/* identifier AMIGA to get the AMIGA version. Thanks to Max and mjl. */
/* ========================================================================= */
/* Yuck! 1.70 isolates a few functions into yucknl.c so that i can rewrite */
/* the crap in assembler without worrying about the Amiga version. intention */
/* is to make the asm- and c-versions of those functions plug-compatible. */
/* ------------------------------------------------------------------------- */
/* Yuck! 1.80 craps this idea. I did implement it, and it was quite a lot */
/* faster than the regular version, but the difference of 3 seconds (on a */
/* total time of 14 for all four lists) is just not worth the trouble of */
/* keeping two versions up-to-date. */
/* ========================================================================= */
/* uncomment the following define to compile an Amiga version */
/* #define AMIGA 1 */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* uncomment the following define to increase file buffer size to FBUFSIZ */
#define BIGBUF 1
#if defined( BIGBUF ) /* what about buffering? */
#define FBUFSIZ 2048 /* file buffer size */
#endif /* BIGBUF */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* uncomment the following define to have the MSC-5.1 optimizer die a quick */
/* and sudden death. will break only when compiled with max optimization. */
/* at least, this worked with 1.30; didn't try for later releases. */
/* #define BREAK_MSC 1 */
/* ------------------------------------------------------------------------- */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#if ! defined( AMIGA )
#include <malloc.h>
#include <process.h>
#else /* AMIGA */
#include <exec/types.h>
#include <exec/memory.h>
#include <proto/exec.h>
#endif /* AMIGA */
/* ------------------------------------------------------------------------- */
#if defined( AMIGA )
#define VER_MACH "[Amiga]"
#define O_RT "ra" /* open for read in translated mode */
#define O_WB "wb" /* open for write in untranslated mode */
#define WILDCARD ".#?"
#define FFNAME fb->fib_FileName
#define MAILDIR "Mail:"
#define hfree free
#define halloc(num,siz) malloc( (num) * (siz) )
#define SORTCMD "sort {in} {out}" /* default sort command */
#define SORTTEMP "Yuck!.temp" /* default temp file name */
#else /* AMIGA */
#define VER_MACH "[MS-DOS]"
#define O_RT "rt" /* open for read in translated mode */
#define O_WB "wb" /* open for write in untranslated mode */
#define WILDCARD ".*"
#define FFNAME fb.name
#define SORTCMD "qsort {in} {out}" /* default sort command */
#define SORTTEMP "yucktemp.$$$" /* default temp file name */
#endif /* AMIGA */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#define VER_NAME "Yuck! 2.00 (" __DATE__ ", " __TIME__ ") "
#define VER VER_NAME VER_MACH
#define HDR ";S A %s pointlist generated by %s -- fake CRC 1 : 0%s"
#define assert(b,l) { \
if ( strlen( b ) > l ) \
printf( "\nassert: '%s'>%u at %s/%u\n", \
b, l, __FILE__, __LINE__ ); \
}
#define skip(s) for ( ; *s && ( *s == ' ' || *s == '\t' ); s ++ )
#define nskip(s) for ( ; *s && ( *s != ' ' && *s != '\t' ); s ++ )
/* ========================================================================= */
#if ! defined( _ALEX_TYPES ) /* my own types */
typedef enum { No, Yes } YesNo; /* I don't like "booleans" */
typedef unsigned char Byte; /* guess what this one is */
typedef unsigned short Word;
#define _ALEX_TYPES 1
#endif
#define CR "\r" /* these are ... */
#define LF "\n" /* ... allowed ... */
#define CRLF "\r\n" /* ... line terminators */
#define EOS ( (Byte) '\0' ) /* string terminator */
#define STRSIZ 39 /* usable chars in a field */
#define MAPINC 32 /* chunk size for "map" allocs */
#define MAXKILL 8 /* max. # of nets to kill */
#define MAXUKILL 8 /* max. # of nodes to kill from userlist */
#define MAXTIM 32 /* max # of tim_fake entries */
#define MAXINC 8 /* max. # of ranges to include in "oldnet" */
#define MAXARGS 64 /* max tokens in sort command */
#define CFGNAME "yuck.ctl" /* default control file */
#define N109FCHR ':' /* trigger char 1 for tim_net */
#define N109CHR '/' /* trigger char 2 for tim_net */
#define POINTNAME "" /* see "sysname" */
#define POINTLOC "Somewhere" /* see "sysloc" */
#define POINTFLAGS "MO" /* see "userlist" */
#define POINTBAUD 2400 /* see "userlist" */
#define POINTADDR 38 /* column after which to search for address */
/* ========================================================================= */
typedef enum { Zone, Region, Host, Hub, Node, Point, Hold, Pvt, Down } eTyp;
static Byte * aTyp[] = { "Zone", "Region", "Host", "Hub", "", "Point",
"Hold", "Pvt", "Down" };
/* ------------------------------------------------------------------------- */
typedef struct _tAd {
Word z, n, f, p;
} tAd;
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
typedef struct _tInc { /* include statement def */
eTyp Type; /* zone, region or net? */
YesNo incHdr; /* hdr & independents only? */
tAd a; /* address referenced */
} tInc;
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* this is the node structure size, less any fill bytes. */
typedef struct _tNod {
struct _tNod * nx; /* next element */
eTyp Type;
YesNo ok; /* == No if not filled in ==> search nodelist */
YesNo prcd; /* == Yes if already processed */
tAd a;
Word No;
Byte Bbs[STRSIZ + 1], City[STRSIZ + 1],
Sysop[STRSIZ + 1], Tel[STRSIZ + 1];
Byte Flags[STRSIZ + 1];
Word Baud;
} tNod;
/* ------------------------------------------------------------------------- */
typedef struct _tCfg {
YesNo killInput; /* must kill input file after proc'g? */
YesNo killUserlist; /* must kill input file after proc'g? */
YesNo killInfd199b; /* must kill input file after proc'g? */
YesNo keepPvt; /* == Yes if private points should be kept */
YesNo putUnpub; /* insert "-Unpublished-"? */
YesNo N109; /* net_109 kludge? */
YesNo Fd199b; /* flag for 1.99b pointlist */
YesNo Clist; /* flag for Amiga Clist format */
YesNo Oldnet; /* flag for old format pointlist */
YesNo doInclude; /* "outfile -a" used? */
YesNo uoInclude; /* "userout -a" used? */
YesNo haveProlog; /* == Yes if prolog file defined */
YesNo haveEpilog; /* == Yes if epilog file defined */
YesNo havePointnet; /* == Yes if "infile" found */
YesNo haveUserlist; /* == Yes if "userlist" found */
YesNo haveInfd199b; /* == Yes if "infd199b" is present */
YesNo haveUserout; /* == Yes if "userout" found */
YesNo haveSysname; /* == Yes is system name not defaulted */
YesNo trimJunk; /* trim tim_net junk? */
Word myZone; /* zone number, if not present in input file */
int maxkill; /* # of kill entries */
int maxukill; /* # of userlist kill entries */
int maxmap; /* # of map entries */
int maxinc; /* "include" entries actually used */
int maxtim; /* current # of tim_fake */
Word killNet[MAXKILL]; /* nets to be removed */
Word timfake[MAXTIM]; /* tim_fake data */
tAd killUser[MAXUKILL]; /* pointnets to be removed from userlist */
Word * mapNet; /* remap source nets */
tAd * mapAd; /* remap target addresses */
Word fakenet; /* fakenet default for tim_net */
tInc incNet[MAXINC]; /* include these into an "oldnet" */
Byte termUser[4]; /* userout line terminator */
Byte termOldnet[4]; /* oldnet line terminator */
Byte termFd199b[4]; /* fd199b line terminator */
Byte termClist[4]; /* clist line terminator */
Byte sysName[40]; /* "userlist" */
Byte sysLoc[40]; /* "userlist" */
Byte sysFlags[40]; /* "userlist" */
Byte iFile[80]; /* input filename */
Byte bFile[80]; /* infd199b filename */
Byte uFile[80]; /* userlist filename */
Byte oFile[80]; /* oldnet output filename */
Byte nFile[80]; /* current nodelist */
Byte fFile[80]; /* fd199b output filename */
Byte cFile[80]; /* clist output filename */
Byte lFile[80]; /* userlist output filename */
Byte pFile[80]; /* prolog file */
Byte eFile[80]; /* epilog file */
Byte tFile[80]; /* pre-sort temp file */
Byte Sort[128]; /* sort command line */
} tCfg;
/* ========================================================================= */
extern tNod * pts; /* start of list */
extern int maxpt; /* next free point entry */
extern int lastpolz; /* index of last include selected by polz() */
extern Word MAXMAP; /* current allocated "map"s */
extern YesNo inPointnet; /* flag var for parseRec() */
extern YesNo inFd199b; /* flag var for parseRec() */
extern tCfg Cfg; /* configuration record */
/* ========================================================================= */
/* externally defined functions */
tNod * addNod( int addCopy, tNod * Node );
void copyProlog( FILE * of, Byte * name, Byte * term );
void delNod( tNod * p );
void dumpList( void );
void dumpRec( tNod * b, FILE * o, int nl );
int find( Word ln, Word * p, int n );
int get109( Byte * str, Word * net, Word * nod );
Byte * getComma( Byte * p, Byte * Temp );
Byte * getLine( Byte * p, FILE * fp, int Cmnt );
void killNets( void );
int main( int argc, Byte * argv[] );
void makeDir( Byte * p );
void makeName( Byte * p );
void mapNets( void );
int needed( tAd a );
tNod * newNod( void );
void parseAd( Byte * p, tAd * a );
void parseRec( Byte * Line, tNod * Buf, int Action );
int polz( eTyp Type, tAd a );
int ptCmp( tNod ** p, tNod ** q );
void readCfg( Byte * cfgName );
void readInfd199b( void );
void readPointnet( void );
void readUserlist( void );
void removeNets( void );
void wrt199bList( FILE * of );
void wrtClist( FILE * of );
void wrtList( FILE * fp, FILE * of );
void wrtRec( tNod * p, FILE * of, YesNo Fd199b, Byte * Term );
void wrtuList( FILE * fp, FILE * of );
void wrtuRec( tNod * p, FILE * of );
/* ========================================================================= */